package com.jetbrains.kmpapp

import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.update

data class InitializationInfo(
    val adsIdentifier: String? = null,
    val deviceIdentifier: String? = null,
    val gravityToken: String? = null,
    val appsflyerToken: String? = null
) {

    val isValid: Boolean
        get() = adsIdentifier != null && deviceIdentifier != null && gravityToken != null

}

data class PlatformConfiguration (
    val isDebug: Boolean, // 是否为 Debug 模式
    val appName: String,  // 应用名称
    val appVersion: String, // 应用版本号 (如 "1.0.0")
    val packageName: String, // Android 上的应用包名，iOS 上的 Bundle Identifier
    val platformName: String, // 平台名称 (如 "Android" 或 "iOS")
    val deviceModel: String, // 设备型号 (如 "Pixel 5" 或 "iPhone 15 Pro")
) {

    private val _initializationInfo = MutableStateFlow(InitializationInfo())
    val initializationInfo: StateFlow<InitializationInfo> = _initializationInfo.asStateFlow()

    internal fun updateInitializationInfo(block: (InitializationInfo) -> InitializationInfo) {
        _initializationInfo.update(block)
    }

}

expect val platformConfiguration: PlatformConfiguration